exports.install = function (Vue, options) {
  //实时更新storage值
  Vue.prototype.resetSetItem = function (key, newVal) {
    // 创建一个StorageEvent事件
    var newStorageEvent = document.createEvent('StorageEvent');
    const storage = {
      setItem: function (k, val) {
        localStorage.setItem(k, val);
        // 初始化创建的事件
        newStorageEvent.initStorageEvent('setItem', false, false, k, null, val, null, null);
        // 派发对象
        window.dispatchEvent(newStorageEvent)
      }
    }
    return storage.setItem(key, newVal);
  },
    //判断添加明细字段是否为空
    Vue.prototype.checkEmy = function(elem){
      let isFieldNotEmy = true;
      for (let i=0; i<$('.' + elem).not(":hidden").length; i++) {
        if ($('.' + elem).eq(i).val() <= 0) {
          isFieldNotEmy = false;
          break;
        }
      }
      return isFieldNotEmy;
    },
    Vue.prototype.serialize2Obj = function (data) {
      var obj = {};
      $.each(data,function(i,v){
        obj[v.name] = v.value;
      })
      return obj;
    },
    //通用toast
    Vue.prototype.toastSuccess = function (text) {
      $.toast(text, 1000);
    },
    Vue.prototype.toastError = function (text) {
      $.toast.prototype.defaults.duration = 1000;
      $.toast(text, 'forbidden');
    },
    Vue.prototype.toastText = function (text) {
      $.toast.prototype.defaults.duration = 1000;
      $.toast(text, 'text');
    },

    //版本号
    Vue.prototype.version = '1.0.8'
};
